package com.sm.user.api.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sm.tool.entity.po.User_;
import com.sm.tool.entity.response.ReturnData;
import com.sm.tool.entity.vo.UserDetailVO;
import com.sm.tool.enums.NumberEnums;
import com.sm.tool.enums.ResultEnums;
import com.sm.user.mapper.UserRegLoginMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: practice
 * @description:
 * @author: liqitian.
 * @create: 2019-11-27 13:59
 **/
@Service
public class UserInsideService {
    @Autowired
    private UserRegLoginMapper userRegLoginMapper;

    public boolean check_exist_admin(Long userId) {
        QueryWrapper<User_> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", userId).eq("state", 1).eq("is_admin", 1);
        if (userRegLoginMapper.selectCount(queryWrapper) == NumberEnums.ZERO.getNumber()) {
            return false;
        }
        return true;
    }

    public User_ getUserInfo(Long userId) {

        QueryWrapper<User_> queryWrapper = new QueryWrapper<>();
        queryWrapper
                .eq("id", userId);
        return userRegLoginMapper.selectOne(queryWrapper);

    }
}
